package model.newhouse.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import model.newhouse.entity.Newhouse;
import model.newhouse.entity.Result;
import model.newhouse.entity.StatusCode;
import model.newhouse.service.INewhouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class GetpageController {
    @Autowired
    private INewhouseService newService;

    @GetMapping("/listpage/{pageNow}")
    public Result findpage(@PathVariable("pageNow") String pageNow){
        Integer pg = Integer.parseInt(pageNow) ;
        PageHelper.startPage(pg,5);
        List<Newhouse> newhouseList = newService.findAll();

        PageInfo<Newhouse> pageInfo = new PageInfo<>(newhouseList);

        Result result = new Result(true, StatusCode.OK,"查询成功",pageInfo);
        return  result;


    }

}
